<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
</head>
<body onload="loginCookie()">
    <form method="post" action="/user/doLogin">
        用户名：<input id="username" name="username"/>
        密码：<input id="password" name="password"/>
        记住我：<input type="checkbox" name="remember" value="1">
        <input type="submit" value="登录"/>
    </form>
</body>
<script>
    function loginCookie() {
        var offset,cookieValue;
        var search="dormuser"+"=";
        if(document.cookie.length>0) {
            offset=document.cookie.indexOf(search);
            if(offset!=-1)
            {
                offset += search.length;
                end = document.cookie.indexOf(";", offset);
                if (end == -1)
                    end = document.cookie.length;
                cookieValue=unescape(document.cookie.substring(offset, end));
            }
        }
        // 不为空，则自动填入
        if (cookieValue != null && cookieValue != undefined && cookieValue != "") {
            var cookies = cookieValue.split("-");
            document.getElementById("username").value = cookies[0];
            document.getElementById("password").value = cookies[1];
        }
    }
</script>
</html>